<template>
    <div id="dr23">
        <Breadcrumb style="margin-bottom: 10px">
            <BreadcrumbItem to="/superAdmin">首页</BreadcrumbItem>
            <BreadcrumbItem>司机管理</BreadcrumbItem>
            <BreadcrumbItem>用户等级管理</BreadcrumbItem>
        </Breadcrumb>
        <Table :maxWidth="1000" :minWidth="10" stripe :columns="columns" :data="data"
               v-if="data&&data.length>0"></Table>


        <div id="loading" v-if="loading">
            <div class="spinner">
                <div class="double-bounce1"></div>
                <div class="double-bounce2"></div>
            </div>
        </div>

    </div>
</template>
<script type="text/ecmascript-6">
    import sessionUtils from '../../model/sessionUtils';
    import ipServer from '../../model/ip';
    import Axios from 'axios';
    export default{
        data(){
            return {
                index: 0,
                loading: false,
                columns: [
                    {
                        title: '用户等级',
                        key: 'level',
                    }, {
                        title: '等级标题',
                        key: 'titleName',
                    },
                    {
                        title: '升级所需经验',
                        key: 'upgrade',
                    },
                    {
                        title: '人数',
                        key: 'count'
                    }
                ],
                data: []
            }
        },
        mounted(){
            this.getData();
        },
        methods: {

            pageChange(page){
                this.getData(page);
            },
            rowData(data, index){
                this.modeData = data;
                this.modeBool = true;
            },
            getData(page){
                var param = new URLSearchParams();
                param.append('mobile', sessionUtils.getSession("mobile"));
                param.append('token', sessionUtils.getSession("token"));
                this.loading = true;
                Axios.post(ipServer + "userLevel/selectAllUserLevel", param)
                        .then(res => {
                            if (res.data.code == 0) {
                                sessionUtils.setSession("token", res.data.token);
                                this.data = res.data.data.result;
                            } else if (res.data.code == 3) {
                                sessionUtils.clear();
                                this.$router.push("/login");
                                this.$Message.info(res.data.msg);
                            } else {
                                this.$Message.info(res.data.msg);
                            }
                            this.loading = false;
                        })
                        .catch(err=> {
                            this.loading = false;
                            if (err.response.status == 504 || err.response.status == 404) {
                                Message.error({message: '服务器被吃了⊙﹏⊙∥'});
                            } else if (err.response.status == 403) {
                                Message.error({message: '权限不足,请联系管理员!'});
                            } else {
                                Message.error({message: '未知错误!'});
                            }
                        });
            }
        }
    }
</script>


<style scoped>
    @import "../../assets/css/loading.css";

</style>